package com.khong.sale.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.khong.sale.ui.OrderListItems;

public class OrderListAdapter extends BaseAdapter {
	private Context mContext;
	private List<OrderListItems> list;

	public OrderListAdapter(Context cotext, List<OrderListItems> list) {
		this.mContext = cotext;
		this.list = list;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public boolean isEnabled(int position) {
		return list.get(position).isClickable();
	}

	@Override
	public int getViewTypeCount() {
		// TODO Auto-generated method stub
		return 2;
	}

	@Override
	public int getItemViewType(int position) {
		// TODO Auto-generated method stub
		return list.get(position).getType();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		switch (getItemViewType(position)) {
		case 1:
			return list.get(position).getView(mContext, convertView,
					LayoutInflater.from(mContext));
		case 0:
			return list.get(position).getView(mContext, convertView,
					LayoutInflater.from(mContext));
		default:
			return null;
		}
		
	}

}
